/**
 * date : 2010-11-05
 * author : Kim Jong-sun
 * comment : MemberServiceImpl 구현
 */
package wetogether.member.service;

import java.sql.SQLException;
import java.util.ArrayList;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


import wetogether.member.dao.MemberDAO;
import wetogether.member.vo.MemberVO;

public class MemberServiceImpl implements MemberService {
	private Log log = LogFactory.getLog(getClass());	// log4j
	private MemberDAO memberDAO;						// 주입 받을 객체변수
	
	/*
	 * 객체 주입을 위한 setter
	 */
	public void setMemberDAO(MemberDAO memberDAO) {
		this.memberDAO = memberDAO;
		log.debug("memberDAO Injection...");
	}
	
	/*
	 * 회원 가입 처리 
	 */
	@Override
	public void registerMember(MemberVO memberVO) throws SQLException {
		memberDAO.insertMember(memberVO);
		log.debug("register : " + memberVO.toString());
	}
	
	/*
	 * 회원 정보 수정
	 */
	@Override
	public MemberVO modifyMemberInfo(MemberVO memberVO) throws SQLException {
		memberDAO.updateMemberInfo(memberVO);
		memberVO = memberDAO.selectMemberInfo(memberVO.getMemberId());
		return memberVO;
	}
	
	/*
	 * 회원 탈퇴
	 */
	@Override 
	public void deleteMember(MemberVO memberVO) throws SQLException {
		memberDAO.deleteMember(memberVO);
	}
	
	/*
	 * 회원 정보 보기
	 */
	@Override
	public MemberVO selectMemberInfo(String memberId) throws SQLException {
		return memberDAO.selectMemberInfo(memberId);
	}
	
	/*
	 * 회원 목록 가져오기
	 */
	@Override
	public ArrayList<MemberVO> selectAllMemberList() throws SQLException {
		return memberDAO.selectAllMemberList();
	}
	
	/*	
	 * 로그인 처리
	 */
	@Override
	public MemberVO login(MemberVO memberVO) throws SQLException {
		return memberDAO.login(memberVO);
	}

	/*
	 * 비밀번호 체크
	 * 
	 */
	@Override
	public String checkPassword(MemberVO memberVO) throws SQLException {
		return memberDAO.checkPassword(memberVO);
	}

	/*
	 * 회원 가입시 아이디 체크
	 */
	@Override
	public String isExistMemberById(String memberId) throws SQLException {
		return memberDAO.isExistMemberById(memberId);
	}
}